body {
    font-family: 'Press Start 2P', cursive;
    background-color: #222;
    color: #eee;
    display: flex;
    justify-content: flex-start; /* Align to top */
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-y: auto; /* Allow scrolling if needed */
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    font-size: 14px; /* Base font size */
}

@font-face {
    font-family: 'Press Start 2P';
    src: url('https://fonts.gstatic.com/s/pressstart2p/v15/8mikIjpKcsQvGgbuU0mYxYh_qE8.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

.container {
    background-color: #333;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 900px;
    width: 100%;
    border: 2px solid #555;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative; /* For z-index context */
}

h1, h2, h3 {
    color: #0f0;
    margin-bottom: 8px;
    text-shadow: 2px 2px #000;
    font-size: 1.5em; /* Adjusted */
}

h2 {
    font-size: 1.3em; /* Adjusted */
}

h3 {
    font-size: 1.1em; /* Adjusted */
    margin-top: 0;
    margin-bottom: 5px;
    color: #0ff;
}

/* Main Menu Styles */
.main-menu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background-color: #333;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 600px;
    width: 100%;
    border: 2px solid #555;
    z-index: 10; /* Ensure it's on top */
}

.main-menu h1 {
    font-size: 2em; /* Adjusted */
    color: #0f0;
    margin-bottom: 15px;
}

.menu-button {
    background-color: #00f;
    color: white;
    padding: 12px 24px; /* Adjusted */
    border: none;
    border-radius: 8px;
    font-size: 1.2em; /* Adjusted */
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 5px 5px #00a;
    font-family: 'Press Start 2P', cursive;
    text-shadow: 2px 2px #000;
    width: 80%;
    max-width: 280px; /* Adjusted */
    letter-spacing: 1px; /* Adjusted */
}

.menu-button:hover { background-color: #00e; transform: translateY(-3px); box-shadow: 7px 7px #00a; }
.menu-button:active { background-color: #00c; transform: translateY(0); box-shadow: 4px 4px #00a; }

/* Game Container - Hidden by default */
.game-container {
    display: none; /* Hidden by default, shown by JS when a mode is selected */
    width: 100%; /* Take full width of parent container */
    flex-direction: column; /* Inherit flex from container */
    gap: 10px; /* Adjusted */
}

/* Top Combat Area (Monster & Player side-by-side) */
.top-combat-area {
    display: flex;
    justify-content: space-around;
    align-items: flex-start; /* Align items to the top */
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* Monster Section */
.monster-section {
    background-color: #444;
    padding: 10px; /* Adjusted */
    border-radius: 8px;
    border: 1px solid #666;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1; /* Allow it to grow and shrink */
    min-width: 220px; /* Adjusted */
    position: relative; /* For absolute positioning of dice slot */
}

.monster-section h2 {
    margin-top: 0;
    color: #f00;
}

.monster-section img {
    width: 90px; /* Adjusted */
    height: 90px; /* Adjusted */
    image-rendering: pixelated;
    border: 3px solid #777;
    border-radius: 8px;
    margin-bottom: 8px;
}

/* Monster Action Display */
.monster-action-display {
    background-color: #3a3a3a;
    padding: 5px;
    border-radius: 5px;
    border: 1px dashed #666;
    margin-top: 8px; /* Adjusted */
    width: 90%;
    text-align: center;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
    display: none; /* Hidden by default */
}

.monster-action-display h4 {
    color: #f80;
    margin: 0 0 5px 0;
    font-size: 0.8em; /* Adjusted */
    text-shadow: 1px 1px #000;
}

.monster-slots {
    display: flex;
    justify-content: center;
    gap: 5px; /* Adjusted */
    min-height: 45px; /* Space for dice */
}

.monster-die-slot {
    width: 40px; /* Smaller dice for monster display */
    height: 40px; /* Adjusted */
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.monster-die-slot img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    object-fit: contain;
}

/* HP Bars */
.hp-bar-container {
    width: 90%;
    height: 18px; /* Adjusted */
    background-color: #555;
    border: 1px solid #777;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    margin-top: 5px;
}

.hp-bar {
    height: 100%;
    width: 100%;
    background-color: #0f0;
    transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 0.7em; /* Adjusted */
    text-shadow: 1px 1px #000;
}

.monster-hp-bar-container .hp-text {
    color: #000;
}

/* Player Section */
.player-section {
    background-color: #444;
    padding: 10px; /* Adjusted */
    border-radius: 8px;
    border: 1px solid #666;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
    flex: 1; /* Allow it to grow and shrink */
    min-width: 220px; /* Adjusted */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* For absolute positioning of dice slot */
}

.player-section h3 {
    margin-bottom: 5px; /* Adjust margin for name */
}

.player-section img {
    width: 90px; /* Adjusted */
    height: 90px; /* Adjusted */
    image-rendering: pixelated;
    border: 3px solid #777;
    border-radius: 8px;
}

.defense-text {
    font-size: 1em; /* Adjusted */
    color: #0ff;
    margin-top: 5px; /* Adjusted */
    text-shadow: 1px 1px #000;
}

/* New: Wrapper for player image and chosen slots */
.character-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Player Dice Pool Area (formerly dice-platform) */
.player-dice-pool-area {
    background-color: #4a4a4a;
    padding: 10px; /* Adjusted */
    border-radius: 8px;
    border: 1px solid #777;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px; /* Adjusted */
    width: fit-content; /* Adjust width to content */
    align-self: center; /* Center horizontally in container */
}

.player-dice-pool-area h2 {
    color: #0f0;
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.3em; /* Adjusted */
}

.dice-display-area {
    display: flex;
    justify-content: center;
    gap: 10px; /* Adjusted */
    flex-wrap: wrap;
    align-items: center;
}

.die-slot {
    width: 60px; /* Adjusted */
    height: 60px; /* Adjusted */
    background-color: #555;
    border: 2px solid #777;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
    box-shadow: 2px 2px #333;
    position: relative;
    overflow: hidden;
}

.die-slot img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    object-fit: contain;
}

.die-slot:hover {
    transform: translateY(-3px);
    box-shadow: 4px 4px #222;
    background-color: #666;
}

/* New: Chosen Action Slots */
.chosen-action-slot {
    position: static; /* No longer absolute */
    transform: none; /* No longer needed */
    width: 50px; /* Adjusted */
    height: 50px; /* Adjusted */
    background-color: #3a3a3a;
    border: 2px dashed #0ff; /* Distinct border for player's action slots */
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1; /* Above other section content */
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
    transition: background-color 0.2s ease, border-color 0.2s ease;
    cursor: grab; /* Indicate draggable content */
}

.chosen-action-slot.has-die {
    background-color: #444; /* Darker when occupied */
    border: 2px solid #0ff; /* Solid border when occupied */
    cursor: pointer; /* Indicate it can be clicked to return */
}

.chosen-action-slot img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    object-fit: contain;
}

#playerSlot1 {
    top: auto;
    left: auto;
    transform: none;
    order: -1; /* Place it before the image in flex container */
}

#playerSlot2 {
    top: auto;
    right: auto;
    transform: none;
    order: 1; /* Place it after the image */
}

/* Confirm Button (now GO Button) */
.confirm-button {
    background-color: #0f0;
    color: white;
    padding: 12px 24px; /* Adjusted */
    border: none;
    border-radius: 8px;
    font-size: 1.5em; /* Adjusted */
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 4px 4px #0a0; /* Adjusted */
    font-family: 'Press Start 2P', cursive;
    text-shadow: 2px 2px #000; /* More prominent text shadow */
    width: auto;
    min-width: 180px; /* Adjusted */
    align-self: center;
    margin-bottom: 10px; /* Adjusted */
    letter-spacing: 2px; /* Adjusted */
}

.confirm-button:hover { background-color: #0e0; transform: translateY(-3px); box-shadow: 6px 6px #0a0; }
.confirm-button:active { background-color: #0c0; transform: translateY(0); box-shadow: 3px 3px #0a0; }

#backToMenuButton {
    align-self: center;
    margin-top: 8px; /* Adjusted */
    margin-bottom: 10px; /* Adjusted */
    width: auto;
    min-width: 200px; /* Adjusted */
}

/* Buttons */
.roll-single-button,
.roll-all-button {
    background-color: #f00;
    color: white;
    padding: 8px 16px; /* Adjusted */
    border: none;
    border-radius: 8px;
    font-size: 1em; /* Adjusted */
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 3px 3px #a00;
    font-family: 'Press Start 2P', cursive;
    text-shadow: 1px 1px #000;
    width: 100%;
    margin-top: auto;
}

.roll-all-button {
    background-color: #00f;
    box-shadow: 3px 3px #00a;
    font-size: 1.2em; /* Adjusted */
    padding: 12px 24px; /* Adjusted */
    margin-top: 15px; /* Adjusted */
    align-self: center;
    width: auto;
    min-width: 200px; /* Adjusted */
}

.roll-single-button:hover { background-color: #e00; transform: translateY(-2px); box-shadow: 5px 5px #a00; }
.roll-single-button:active { background-color: #c00; transform: translateY(0); box-shadow: 2px 2px #a00; }

.roll-all-button:hover { background-color: #00e; transform: translateY(-2px); box-shadow: 5px 5px #00a; }
.roll-all-button:active { background-color: #00c; transform: translateY(0); box-shadow: 2px 2px #00a; }

button:disabled {
    background-color: #666;
    box-shadow: 3px 3px #333;
    cursor: not-allowed;
    transform: none;
}
button:disabled:hover {
    background-color: #666;
    box-shadow: 3px 3px #333;
    transform: none;
}

.results {
    margin-top: 20px; /* Adjusted */
    background-color: #444;
    padding: 15px; /* Adjusted */
    border-radius: 8px;
    border: 1px solid #666;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

.results h2 {
    color: #0f0;
    margin-top: 0;
    text-shadow: 1px 1px #000;
    font-size: 1.5em; /* Adjusted */
}

.results p {
    font-size: 1.1em; /* Adjusted */
    color: #eee;
}

.results span {
    font-weight: bold;
    color: #ff0;
}

/* Game Log */
.game-log {
    margin-top: 5px; /* Adjusted */
    background-color: #444;
    padding: 10px; /* Adjusted */
    border-radius: 8px;
    border: 1px solid #666;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
    text-align: left;
}

.game-log h2 {
    color: #0f0;
    margin-top: 0;
    text-shadow: 1px 1px #000;
    font-size: 1.3em; /* Adjusted */
}

.game-log ul {
    list-style: none;
    padding: 0;
    max-height: 100px; /* Adjusted */
    overflow-y: auto;
    border-top: 1px solid #555;
    padding-top: 5px;
}

.game-log li {
    margin-bottom: 3px;
    font-size: 0.8em; /* Adjusted */
    line-height: 1.3; /* Adjusted */
    color: #eee;
}

/* Dice Roll Animation */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

.die-slot img.rolling {
    animation: shake 0.3s ease-in-out;
}

/* New: Drag Over visual feedback */
.die-slot.drag-over,
.chosen-action-slot.drag-over,
.dice-display-area.drag-over { /* dice-display-area is availableDiceContainer */
    box-shadow: 0 0 15px 5px rgba(0, 255, 255, 0.7); /* Cyan glow */
    border-color: #0ff;
    transform: scale(1.02); /* Slight scale to emphasize */
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        font-size: 12px; /* Further reduce base font size on small screens */
    }
    .container {
        padding: 10px;
        gap: 8px;
    }
    .top-combat-area {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    .monster-section, .player-section {
        width: 100%; /* Take full width */
        min-width: unset; /* Remove min-width to allow shrinking */
    }
    .character-display {
        gap: 5px;
    }

    .player-section img, .monster-section img {
        width: 75px;
        height: 75px;
    }

    .chosen-action-slot {
        width: 45px;
        height: 45px;
    }
    
    .player-dice-pool-area {
        width: 100%;
        padding: 8px;
    }
    .player-dice-pool-area h2 {
        font-size: 1.1em;
    }
    .dice-display-area {
        gap: 8px;
    }
    .die-slot {
        width: 50px;
        height: 50px;
    }

    .menu-button {
        font-size: 1.1em;
        padding: 10px 20px;
    }
    .confirm-button {
        font-size: 1.3em;
        padding: 10px 20px;
        min-width: 150px;
    }

    .game-log ul {
        max-height: 80px;
    }
}